<?php include('header.php'); ?>
<?php
include_once('../lib/Sqlexecutor.php');
include_once('../lib/Tile.php');

$dbh = new Sqlexecutor('localhost', 'tile', 'tile', 'tile');
$t = new Tile($dbh);
$list = $t->getListWithAvgPriceBySeriesID();
$list = $t->sort_by_avg_price($list);
?>

			<div>
				<ul class="breadcrumb">
					<li>
						<a href="#">数据分析</a> <span class="divider">/</span>
					</li>
					<li>
						<a href="#">瓷砖平均价格</a>
					</li>
				</ul>
			</div>
			
			<div class="row-fluid sortable">		
				<div class="box span12">
					<div class="box-header well" data-original-title>
						<h2><i class="icon-user"></i> 瓷砖信息</h2>
						<div class="box-icon">
							<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
							<a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>
						</div>
					</div>
					<div class="box-content">
						<table class="table table-striped table-bordered bootstrap-datatable datatable1">
						  <thead>
							  <tr>
								  <th>型号</th>
								  <th>尺寸</th>
								  <th>材质</th>
								  <th>类型</th>
								  <th>平均价格</th>
								  <th>平均评分</th>
								  <th>上线时间</th>
							  </tr>
						  </thead>   
						  <tbody>
<?php
foreach($list as $info) { ?>
							<tr>
                                <td class="center"><?php echo $info['number'];?></td>
                                <td class="center"><?php echo $info['length'] . ' * ' . $info['width']?></td>
                                <td class="center"><?php echo $info['texture'];?></td>
                                <td class="center"><?php echo $info['class'];?></td>
                                <td class="center"><?php echo $info['avg_price'];?></td>
                                <td class="center"><?php echo $info['avg_score'];?></td>
                                <td class="center"><?php echo $info['insert_date'];?></td>
							</tr>
<?php }?>
						  </tbody>
					  </table>            
					</div>
				</div><!--/span-->
			</div><!--/row-->
   
<?php include('footer.php'); ?>

<script>
$().ready(function() {
	//datatable
	$('.datatable1').dataTable({
			"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span12'i><'span12 center'p>>",
			"sPaginationType": "bootstrap",
            "aaSorting": [[6, "asc"]],
			"oLanguage": {
			"sLengthMenu": "每页显示 _MENU_"
			}
		} );

	
});
</script>
